/*
 * FileUtils.java
 *
 * Created on 01 March 2007, 16:31
 *
 * Copyright (C)
 * This program is free software; you can redistribute it and/or modify it under 
 * the terms of the GNU General Public License as published by the Free Software 
 * Foundation; either version 2 of the License, or (at your option) any later 
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with 
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */

package com.grubby.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 *
 * @author A. HARMEL-LAW. E: andrew.harmel.law@gmail.com
 * @version 0.1
 */
public class FileUtils {
    
    /** Creates a new instance of FileUtils */
    public FileUtils() {
    }
    
//    /**
//     * A non destructive line extractor. Takes a handle to a file, reads through 
//     * it line by line, and writes all lines which match the regex pattern(s) 
//     * provided to the output file.
//     * @param fileIn The file to be read
//     * @param fileOut The file to write the results to
//     * @param patterns A String array containing the the regex patterns to use
//     * when matching
//     * @throws
//     */
//    public static void extractLinesFromFile(File aFileIn, String aFileNameOut,
//            String regex[]) {
//    
////        InputStream fileStream = FileUtils.class.getResourceAsStream("/com/andrewbrucelaw/utils/" + aFilename);
////        
////        BufferedReader reader = new BufferedReader.
//        
//        Scanner myScanner = null;
//        try {
//            myScanner = new Scanner(aFileIn);
//        } catch (FileNotFoundException e) {
//            System.out.println("The file was not found!");
//        }
//        
//        Writer myWriter = new FileWriter(aFileNameOut);
//            
//        
//        while (myScanner.hasNext()) {
//            String nextGUID = myScanner.next()
//        }
////        
////        // Compile the regex Strings to Patterns
////        Pattern patterns[] = new Pattern[regex.length];
////        for (int i = 0 ; i < regex.length ; i ++) {
////            patterns[i] = Pattern.compile(regex[i]);
////        }
////        
////        while (fileIn.) {
////            fileIn.
////        }
//    }

    public static void readFile(String aFileName) {
        try {
         File file = new File(aFileName);
         Scanner scanner = new Scanner(file);
         while (scanner.hasNext()) {
           System.out.println(scanner.next());
         }
         scanner.close();
       } catch (FileNotFoundException e) {
         e.printStackTrace();
       }
    }
    
}
